package com.boot.controller;

import com.boot.business.PurchaseDTO;
import com.boot.result.Result;
import com.boot.service.StorageService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("storage")
@AllArgsConstructor
public class StorageController {
    private final StorageService storageService;


    @GetMapping("/{id}")
    public Result getStorageByProductId(@PathVariable Long id){
        return storageService.getStorageByProductId(id);
    }

    @PostMapping("/deduct")
    public Result deduct(@RequestBody PurchaseDTO purchaseDTO){
        return storageService.deduct(purchaseDTO);
    }
}
